<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/common.js"></script>
</head>
<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "strategyCatalog" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>攻略分类管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategyCatalog/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                        <label>攻略搜索</label>
                        <select id="strategySelect" name="strategyId" class="form-control form-control-chosen" data-placeholder="请选择所属攻略" >
                            <option value="-1">全部</option>
                            <#list strategys as s>
                              <option value="${s.id}">${s.title}</option>
                            </#list>
                        </select>
                        <script>
                            $("#strategySelect").val(${(qo.strategyId)!});
                        </script>
                    </div>
                    <button id="btn_query" class="btn btn-success">
                        <span class="glyphicon glyphicon-search"></span> 查询
                    </button>
                    <a  class="btn btn-success inputBtn" >添加攻略分类</a>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>分类名称</th>
                        <th>所属攻略</th>
                        <th>排序</th>
                        <th>状态</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td>${entity.name}</td>
                        <td>${entity.strategy.title}</td>
                        <td>${entity.sequence}</td>
                        <td>${entity.stateName}</td>
                        <td>
                            <a href="javascript:void(0);" class="inputBtn"  data-json='${entity.json}'>修改</a>
                        </td>
                    </tr>
					</#list>
                    </tbody>
                </table>
              <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>

<div id="strategyCatalogModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="inputForm" class="form-horizontal" method="post" action="/strategyCatalog/saveOrUpdate.do" enctype="multipart/form-data" style="margin: -3px 118px">
                    <input id="id" type="hidden" name="id" value="" />
                    <div class="form-group">
                        <label class="col-sm-4 control-label">分类名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name" placeholder="名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属攻略</label>
                        <div class="col-sm-6">
                            <select id="strategy" class="form-control" autocomplete="off" name="strategy.id">
                                <#list strategys as s>
                                    <option value="${s.id}">${s.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">排序</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态</label>
                        <div class="col-sm-6">
                            <select id="state" class="form-control" autocomplete="off" name="state" >
                                <option value="false">禁用</option>
                                <option value="true">启用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        //修改按钮
        $(".inputBtn").click(function () {
            //清空模态框
            $("#inputForm input").val("");
            $("#inputForm select").val("");
            //获取自定义的json属性
            var json=$(this).data("json");
            if(json){
                //回显隐藏域的id
             $("#id").val(json.id);
             $("#name").val(json.name);
             $("#strategy").val(json.strategyId);
             $("#sequence").val(json.sequence);
             $("#state").val(json.state+"");//这里的state是true和false,把布尔类型变成字符串再赋值
              }else{
                //新增操作,回显当前的大攻略目录
                $("#strategy").val($("#strategySelect").val());
            }
            $("#strategyCatalogModal").modal("show");
        });
        //推荐按钮提交
        $("#saveBtn").click(function () {
            $("#inputForm").ajaxSubmit(function (data) {
                doSuccess();
            });
        });
    });
</script>

</body>
</html>